const path = require('path');
module.exports = {
  entry: path.resolve(__dirname, './src/index.js'),
  output: {
    path: path.resolve(__dirname, './h5/out'),
    filename: 'bundle.js' 
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env']
          }
        }
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader']
      },
      {
        test: /\.(png|jpg|gif)$/,
        use: [
          {
            loader: 'url-loader?name=images/[path][hash:8].[name].[ext]',
            options: {
              limit: 8000,
              esModule: false,
              outputPath: 'images/',
              publicPath : './out/images'
            }
          }
        ]
      },
      {
        test: /\.(html)$/,
        use: {
          loader: 'file-loader?name=[path][hash:8][name].[ext]!extract-loader!html-loader',
          options: {
            attrs: [':data-src']
          }
        }
      } 
    ]
  },
  mode: 'production'
};
